#pragma once

#ifndef _CTRANSPORT_H_
#define _CTRANSPORT_H_

#include "structs.h"
#include "define.h"
#include "CChar.h"

class CTransport
{
public:
		
	unsigned char m_id;
	unsigned char m_type;
	unsigned char m_name[30];

	// Times based on minutes after every 6hrs Vana time
	unsigned short m_timeArrive;
	unsigned short m_timeArriveEvent;

	unsigned short m_timeDock;

	// Event plays always at depart time for chars on transport
	unsigned short m_timeDepart;

	// NPC name
	unsigned char m_NPCname;

	// airships have 2 NPCs, need to verify if boats, barges have 1 or 2
	unsigned short m_targId1, m_targId2;

	unsigned char m_dockZone, m_transportZone;

	// invisible door to open/close when docking/departing transport
	unsigned short m_dockTargId;

	// Boundary ID for transport, client reported to server using packet 0xF2
	unsigned short m_dockBoundaryId;

	// x, y, z, rotation for transport when docked
	position m_dockPos;

	// x, y, z, rotation for characters to appear when docked
	position m_charDockPos;

	// transport animations for chars not on transports
	unsigned char m_departAnim, m_arrivalAnim;

	// event IDs
	unsigned int m_arrivalEventId, m_departEventId, m_transEventId;

	// transport is arriving, prevents docking/departing of transports that never arrived
	bool m_arriving;

	// functions
	CTransport::CTransport();
	CTransport::~CTransport();

	void CTransport::arriveAnim();
	void CTransport::arriveEvent();
	void CTransport::dock();
	void CTransport::depart();
	void CTransport::despawn();

	// update transport NPCs when status changes
	void CTransport::updateTransNPCs(unsigned short transportStatus);

	// resets transport NPCs to despawned and docks to closed, used on loading
	void CTransport::resetTransNPCs();

	// returns string "airship, "boat", "barge" from type
	char * CTransport::typeToString();

	// returns transport zone from dock boundary ID
	static char CTransport::getTransZone(unsigned short boundaryId);

	// returns true is transport has called arriveAnim() and false for despawn()
	bool CTransport::isArriving();

	// returns true if char is behind dock's invisible door
	bool CTransport::isCharOnTransport(CChar * schar);
};

#endif